
#define _GNU_SOURCE
#define __USE_GNU

#include <stdio.h>
#include <unistd.h>
#include <linux/futex.h>
#include <time.h>
#include <sys/time.h>
#include <sys/syscall.h>
#include <sched.h>
#include <errno.h>
#include <fcntl.h>

//this file was full of bugs

int thread(void *p) {
        printf("thread: %ld %d\n", syscall(SYS_gettid), getpid());
        return 0;
}

main() {
        unsigned char stack[4096];
        int i;

        i = clone(thread, stack+2048, CLONE_THREAD|CLONE_SIGHAND|CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_PARENT, NULL);
        if (i == -1)
                perror("clone");
        else
                printf("clone returns %d\n", i);
        printf("parent: %ld %d\n", syscall(SYS_gettid), getpid());
}
